package yun.web.springmvc;


import io.undertow.servlet.api.InstanceFactory;
import io.undertow.servlet.api.InstanceHandle;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.WebApplicationContext;


public class ContextLoaderListenerInstanceFactory implements
        InstanceFactory<ContextLoaderListener> {

    private WebApplicationContext webApplicationContext;

    public ContextLoaderListenerInstanceFactory(WebApplicationContext webApplicationContext) {
        this.webApplicationContext = webApplicationContext;
    }


    public InstanceHandle<ContextLoaderListener> createInstance()
            throws InstantiationException {
        ContextLoaderListenerInstanceHandle ContextLoaderListenerInstanceHandle = new ContextLoaderListenerInstanceHandle();
        return ContextLoaderListenerInstanceHandle;
    }

    class ContextLoaderListenerInstanceHandle implements
            InstanceHandle<ContextLoaderListener> {

        @Override
        public ContextLoaderListener getInstance() {

            ContextLoaderListener ContextLoaderListener = new ContextLoaderListener(webApplicationContext);
            return ContextLoaderListener;
        }

        @Override
        public void release() {
            // TODO Auto-generated method stub
        }

    }

}